package com.mengze.linlee_iot_adnroid.ui.home

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.HorizontalScrollView


class CenterScrollView : HorizontalScrollView {
    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

    fun centerItem(itemView: View) {


        post {
            val targetPos = itemView.left - (width - itemView.width) / 2
            smoothScrollTo(targetPos, 0)
        }
    }
}
